package com.itheima.tanhua.dubbo.mappers;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.tanhua.domain.UserInfo;
import com.itheima.tanhua.dto.RecommendUserDto;
import com.itheima.tanhua.mongo.RecommendUser;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author Lff
 * @date 2022/3/24
 */
public interface UserInfoMapper extends BaseMapper<UserInfo> {

    @Select("select * FROM tb_user_info where id IN (" +
            "select black_user_id from tb_black_list b WHERE user_id = #{uid})")
    IPage<UserInfo> findPageByUserIds(@Param("pages") Page pages, @Param("uid") Long uid);

    Page<UserInfo> findUserInfosToPage(@Param("page") Page<UserInfo> userInfoPage,
                                       @Param("ids") List<RecommendUser> items,
                                       @Param("condition") RecommendUserDto dto);

    @Select("SELECT " +
                "ui.id,ui.nickname,ui.avatar,ui.tags,ui.gender,ui.age,ui.education,ui.city,ui.birthday," +
                "ui.cover_pic,ui.profession,ui.income,ui.created,ui.updated,ui.marriage " +
            "FROM " +
                "tb_user user,tb_user_info ui " +
            "WHERE " +
                "user.id = ui.id " +
            "AND " +
                "user.hx_user=#{hxUser}")
    UserInfo findByHxUser(@Param("hxUser") String hxUser);
}
